package com.holystone.splunk.app.enums;

/**
 * Copyright (c) 2017, HOLYSTONE Technologies, Inc.
 * All right reserved.
 *
 * @author huyan
 * @date 2017/11/3
 * @desc:
 */
public class AlertEnums {

    // 告警级别枚举
    public enum AlertLevelEnum {
        LEVEL_INFO(1, "信息"),
        LEVEL_LOW(2, "低"),
        LEVEL_MEDIUM(3, "中"),
        LEVEL_HIGH(4, "高"),
        LEVEL_CRITICAL(5, "严重");

        private Integer level; // 状态数字
        private String levelInfo; // 状态字符

        AlertLevelEnum(Integer level, String levelInfo) {
            this.level = level;
            this.levelInfo = levelInfo;
        }

        public Integer getLevel() {
            return level;
        }

        public String getLevelInfo() {
            return levelInfo;
        }

        public static String getLevelMsg(Integer levelNum) {
            if (levelNum == null) {
                return "";
            }

            for (AlertLevelEnum levelEnum : values()) {
                if (levelNum.intValue() == levelEnum.getLevel()) {
                    return levelEnum.getLevelInfo();
                }
            }
            return "";
        }
    }

    public enum AlertStateEnum {

        STATE_UNLINK(0, "新生告警"),
        STATE_LINK(1, "已关联"),
        STATE_CLOSE(2, "已关闭");

        private Integer stateCode;
        private String stateInfo;

        AlertStateEnum(Integer stateCode, String stateInfo) {
            this.stateCode = stateCode;
            this.stateInfo = stateInfo;
        }

        public Integer getStateCode() {
            return stateCode;
        }

        public String getStateInfo() {
            return stateInfo;
        }

        public static String getStateMsg(Integer stateCode) {
            if (stateCode == null)
                return "";
            for (AlertStateEnum state : values()) {
                if (stateCode.intValue() == state.getStateCode()) {
                    return state.getStateInfo();
                }
            }
            return "";
        }
    }

}
